<?php
/*
更新内容浏览页面的点击次数
*/
require_once('global.php');

$tid = intval($_GET['tid']);
$cid = intval($_GET['cid']);
if(!$tid) exit;
unset($_GET,$_POST,$_REQUEST);

require_once(D_P.'data/cache/cate_'.$cid.'.php');
!$cateinfo && exit;
if($cateinfo['mid']>0){
	$rs = $db->get_one("SELECT hits,comnum FROM cms_contentindex WHERE tid='$tid'");
}else if ($cateinfo['mid']==-2) {
	require_once(R_P.'require/class_bbs.php');
	$bbs = new BBS();
	$hits = $bbs->getField('hits');
	$replies = $bbs->getField('replies');
	$rs = $bbs->mysql->get_one("SELECT $hits AS hits,$replies AS comnum FROM $bbs->table WHERE tid='$tid'");
}
!$rs['hits'] && $rs['hits'] = 1;
!$rs['comnum'] && $rs['comnum'] = 0;

Cookie($tid,'1',$timestamp+600);
print <<<EOT
var hits = document.getElementById('hits');
hits.innerHTML = '{$rs[hits]}'; 
var comnum = document.getElementById('comnum');
comnum.innerHTML = '{$rs[comnum]}'; 
EOT;
if(!GetCookie($tid)){
	$db->update("UPDATE cms_contentindex SET hits=hits+1 WHERE tid='$tid'");
}
?>